'use strict';

const BaseController = require('../base');

class BannerController extends BaseController {
  static get serviceName() {
    return 'business.collection';
  }
  async collectionProduct() {
    const { ctx } = this;
    let where = {}
    if (ctx.query.user_id && ctx.query.type) {
      where = {
        user_id: ctx.query.user_id,
        type: ctx.query.type
      }
      if (ctx.query.news_id) {
        where.news_id = ctx.query.news_id
      }
      if (ctx.query.product_id) {
        where.product_id = ctx.query.product_id
      }
    }
    const res = await this.ctx.model.Business.Collection.findOne({
      where
    })
    this.ctx.success(res);
  }
}

module.exports = BannerController;
